<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ include file="/page/user/gerenHeader.jsp" %>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>确认订单 | 饿9定</title>
<script src="<%=basePath %>js/jquery-2.0.3.min.js" type="text/javascript"></script>
<style type="text/css">
tr td{
/* border: 1px solid red; */
}
</style>
</head>
<body style="background-image: url(<%=basePath%>image/info.jpg)">
<form action="order_saveOrder" method="post">
<s:hidden value="%{comId}" name="comId"></s:hidden>
<s:hidden value="%{userId}" name="userId"></s:hidden>
<div style="width: 800px;height: 630px;margin: 0px auto;background-color:white">
<div  style="width: 400px;height: 90px;font-family:'微软雅黑';font-size:30px;border-bottom-color: ">
<img alt="" src="<%=basePath%>upload/<s:property value='company.comImage'/>" width="90px;" height="90px;"><s:property value="company.comName"/>
</div>
<div style="width: 800px;height: 300px;">
<table>
<tr height="40px;" style="border: 1px solid #C0C0C0;">
<td width="500px;" style="border: 1px solid #C0C0C0;">菜篮子</td>
<td width="100px;" style="border: 1px solid #C0C0C0;">单价</td>
<td width="100px;" style="border: 1px solid #C0C0C0;">数量</td>
<td width="100px;" style="border: 1px solid #C0C0C0;">总计</td>
</tr>
<s:iterator value="cartOrders" id="cart">
<tr height="40px;"><td width="500px;"><s:hidden value="%{#cart.cartId}" name="cartId"></s:hidden><s:property value="#cart.menuName"/></td><td width="100px;"><s:property value="#cart.menuPrice"/></td><td style="display:none" class="pronum" ><s:property value="#cart.menuNum"/></td><td width="100px;"><input type="button" value="-" class="min" style="width: 20px;height: 20px;margin-left:15px;"/><input type="text" value="<s:property value="#cart.menuNum"/>" class="text_box" name="num" style="width: 30px;height: 25px"/><input type="button" class="add" value="+" style="width: 20px;height: 20px"/></td><td width="100px;"><s:property value="#cart.menuTotalPrice"/></td></tr>
</s:iterator>
</table>
</div>
<div style="width: 800px;height: 40px;font-family:'微软雅黑';font-size:20px;border-bottom:1px solid #C0C0C0;">
<div style="width:150px;height:100%;float:right;">应付金额<span id="money"><s:property value="profit"/></span>元</div>
<div style="width:150px;height:100%;float:right;">共<span id="pnum"><s:property value="num"/> </span>份</div>
</div>
<script type="text/javascript">
$(function () {
	$(".add", this).bind("click", function() {
		var t = $(this).parents("tr").find(".text_box");
		t.val(parseInt(t.val()) + 1)
		var changenum = $(this).parents("tr").find(".text_box").val();
	$(this).parents("tr").find(".pronum").text(changenum);
	var sum=0;
	var num1=0;
	var trs=document.getElementsByTagName("tr");
    //alert(trs.length);
	for(var i=1;i<trs.length;i++){
		var num=trs[i].childNodes[2].innerHTML;
		///alert(num);
		var price=trs[i].childNodes[1].innerHTML;
		//alert(price);
		trs[i].childNodes[4].innerHTML=parseFloat(price)*parseInt(num);
		
		num1+=parseInt(num);
		sum+=parseFloat(price)*parseInt(num);
	}
	
	document.getElementById("pnum").innerHTML=num1;
	document.getElementById("money").innerHTML =sum; 
	})
	$(".min", this).bind("click", function() {
		var t = $(this).parents("tr").find(".text_box");
		if(t.val()>0){
			t.val(parseInt(t.val()) - 1)
			var changenum = $(this).parents("tr").find(".text_box").val();
			$(this).parents("tr").find(".pronum").text(changenum);
			var sum=0;
			var num1=0;
			var trs=document.getElementsByTagName("tr");
			for(var i=1;i<trs.length;i++){
				var num=trs[i].childNodes[2].innerHTML;
				var price=trs[i].childNodes[1].innerHTML;
				trs[i].childNodes[4].innerHTML=parseFloat(price)*parseInt(num);
				num1+=parseInt(num);
				sum+=parseFloat(price)*parseInt(num);
			}
			document.getElementById("pnum").innerHTML=num1;
			document.getElementById("money").innerHTML =sum; 
		}
	})
})
</script>
<div style="width: 800px;height: 40px;font-family:'微软雅黑';font-size:18px;">
备&nbsp;&nbsp;注：<input type="text" name="order.userRemark" style="width: 300px;height: 30px;"/>
</div>
<div style="width: 800px;height: 40px;font-family:'微软雅黑';font-size:18px;">
地&nbsp;&nbsp;址：
<select style="width: 130px;height: 30px;" name="street">
<option>----请选择街道---</option>
<s:iterator value="streets" id="street">
<option value=""><s:property value="#street.streetName" /></option>
</s:iterator>
</select>
<input type="text" name="address" style="width: 300px;height: 30px;"/>
</div>
<div style="width: 800px;height: 40px;font-family:'微软雅黑';font-size:18px;">
联系电话：<input type="text" name="order.userPhone" style="width: 300px;height: 30px;"/>
</div>
<div style="width: 800px;height: 40px;font-family:'微软雅黑';font-size:18px;">
支付方式：<input type="radio" name="order.payType" value="1"/>餐到付款<input type="radio" name="order.payType" value="0" checked="checked"/>在线支付
</div>
<div style="width: 800px;height: 40px;font-family:'微软雅黑';font-size:18px;">
<input type="submit" value="确认订单" style="width: 250px;height:40px;font-size:18px;margin-left: 300px;"/>
</div>
</div>
</form>
</body>
<%@ include file="/page/user/userFooter.jsp"%>
</html>